package com.ww.core.util;

import android.content.Context;
import android.content.SharedPreferences;

import com.ww.core.R;

/**
 * 
 * 本地简单数据保存工具类.
 * @version 2013-3-22
 * @author wangw
 */
public class CoreSharedPreferencesHelper {
	private static final String PREFS_NAME = "sdfg";
	private Context context;

	/**
	 * 构造方法.
	 * @param context Context
	 */
	public CoreSharedPreferencesHelper(Context context) {
		this.context = context;
	}

	/**
	 * 保存数据.
	 * @param key key
	 * @param value 值
	 */
	public void setValue(String key, String value) {
		SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, 0);
		SharedPreferences.Editor editor = settings.edit();
		editor.putString(key, value);
		editor.commit();
	}

	/**
	 * 获取数据.
	 * @param key key
	 * @return  值
	 */
	public String getValue(String key) {
		SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, 0);
		String hello = settings.getString(key, null);
		return hello;
	}

	/**
	 * 获取主题.
	 * @return 主题名 （默认：blue）
	 */
	public String getTheme() {
		SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, 0);
		String hello = settings.getString("theme", context.getResources().getString(R.string.moren));
		return hello;
	}

	/**
	 * 保存主题.
	 * @param theme 主题名
	 */
	public void setTheme(String theme) {
		SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, 0);
		SharedPreferences.Editor editor = settings.edit();
		editor.putString("theme", theme);
		editor.commit();
	}
}
